package com.zsrt.java.day20170112.lh.daily.ch04;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.junit.Test;

public class copyTest {
	
	@Test
	public void testName() throws Exception {
		
		//找到源文件
		
		File file=new File("c:/A.txt");
		
		//把目标文件的内容读出
		String read = util.FlieUtil.read("c:/A.txt");
		
		
		//写入文件中
		util.FlieUtil.write(read, "c:/B.txt");
		
	}
	
	
	@Test
	public void appendWrite() throws Exception {
		
		File file=new File("c:/A.txt");
		
		String read=util.FlieUtil.read("c:/A.txt");
		
		String n=read+"刘浩刘浩";
	    util.FlieUtil.write(n, "c:/A.txt");
		
		
	
	}
	
	@Test
	public void test1() throws Exception {
		util.FlieUtil.appendWrite("c:/A.txt", "haadajfkajkfjdjfa刘浩");
		
	}
	
	@Test
	public void testName23() throws Exception {
		
		File in=new File("c:/A.txt");
		File ou=new File("c:/B.txt");
		
		FileInputStream fis=new FileInputStream(in);
		
		FileOutputStream fos=new FileOutputStream(ou);
		
		System.out.println(in.length());
		byte[] b=new byte[1024];
		int len=0;
		while((len=fis.read(b))!=-1){
			fos.write(b, 0, len);
		}
		
		//关闭流 后来的先关
		
		fos.close();
		fis.close();
	}

}
